const STATION_LIST_KEY = "STATION_LIST_KEY";
const FACTORY_LIST_KEY = "FACTORY_LIST_KEY";
const PARAMETER_LIST_KEY = "PARAMETER_LIST_KEY";
const ADMINISTRATIVE_DIVISION_LIST_KEY = "ADMINISTRATIVE_DIVISION_LIST_KEY";

export default class ConfigData {
    static setStationList(list) {
        wx.setStorage({
            key: STATION_LIST_KEY,
            data: list,
        });
    }

    static setFactoryList(list) {
        wx.setStorage({
            key: FACTORY_LIST_KEY,
            data: list,
        });
    }

    static setParameterList(list) {
        wx.setStorage({
            key: PARAMETER_LIST_KEY,
            data: list,
        });
    }

    static setAdministrativeDivisionList(list) {
        wx.setStorage({
            key: ADMINISTRATIVE_DIVISION_LIST_KEY,
            data: list,
        });
    }

    static  getStationList() {
        return wx.getStorageSync(STATION_LIST_KEY);
    }

    static  getFactoryList() {
        return wx.getStorageSync(FACTORY_LIST_KEY);
    }

    static getParameterList() {
        return wx.getStorageSync(PARAMETER_LIST_KEY);
    }

    static getAdministrativeDivisionList() {
        return wx.getStorageSync(ADMINISTRATIVE_DIVISION_LIST_KEY);
    }

    static getStationMap() {
        let stationList = ConfigData.getStationList();
        let stationMap = {};
        for (let i = 0; i < stationList.length; i++) {
            let bean = stationList[i];
            stationMap[bean.id] = bean;
        }
        return stationMap;
    }
}